package com.example.test;

import controller.Controlador;
import android.support.v7.app.ActionBarActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class PublicarActivity extends ActionBarActivity {
	
	EditText tituloPub;
	EditText textoPub;
	Button publicarBtn;
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_publicar);
		
		
		
		tituloPub = (EditText) findViewById(R.id.tituloPublicacionEditText);
		textoPub = (EditText) findViewById(R.id.textoPublicacionEditText);
		publicarBtn = (Button) findViewById(R.id.publicarBoton);
		
		
		publicarBtn.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				Controlador.publicar(domain.Sesion.username, tituloPub.getText().toString(), textoPub.getText().toString());
				Intent back = new Intent(PublicarActivity.this,LogeadoActivity.class);
        		startActivity(back);
			}
		});	
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.publicar, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle action bar item clicks here. The action bar will
		// automatically handle clicks on the Home/Up button, so long
		// as you specify a parent activity in AndroidManifest.xml.
		int id = item.getItemId();
		if (id == R.id.action_settings) {
			return true;
		}
		return super.onOptionsItemSelected(item);
	}
}
